Skip to content

feat(runtime): add Response.redirect() and Response.json()#5046

Merged
jedel1043 merged 3 commits intoboa-dev:mainfrom
iammdzaidalam:feat/response-statics
Mar 18, 2026
Merged

feat(runtime): add Response.redirect() and Response.json()#5046
jedel1043 merged 3 commits intoboa-dev:mainfrom
iammdzaidalam:feat/response-statics

Conversation

@iammdzaidalam
Copy link
Contributor

@iammdzaidalam iammdzaidalam commented Mar 13, 2026

Resolves #5042

This adds Response.redirect() and Response.json() to the fetch runtime.

Response.error() was already exposed as a static constructor, but the other two spec-defined constructors were still missing.

The change is localized to core/runtime/src/fetch/response.rs with the corresponding tests in core/runtime/src/fetch/tests/response.rs.

Added

  • Response.redirect(url, status)

    • defaults to 302
    • validates redirect status
    • sets the Location header
  • Response.json(data, init)

    • serializes the provided value as JSON
    • applies optional response init fields
    • sets Content-Type: application/json if it is not already present

Tests

Added coverage for:

  • default redirect status
  • custom redirect status
  • invalid redirect status
  • JSON response body and content type
  • preserving explicit Content-Type
  • applying init.status

Spec:

@iammdzaidalam iammdzaidalam requested a review from a team as a code owner March 13, 2026 20:39
@github-actions
Copy link

github-actions bot commented Mar 13, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,073 50,073 0
Ignored 2,072 2,072 0
Failed 818 818 0
Panics 0 0 0
Conformance 94.54% 94.54% 0.00%

Tested main commit: daf86d30277a5c1fb353825347f75c1d83516905
Tested PR commit: 096a0ca95bf0114ee8e56e34b62ac78de32cd1dc
Compare commits: daf86d3...096a0ca

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jedel1043
Copy link
Member

Ping me after resolving the conflicts so that I can merge

@jedel1043 jedel1043 added A-Enhancement New feature or request C-Builtins PRs and Issues related to builtins/intrinsics Waiting On Author Waiting on PR changes from the author labels Mar 18, 2026
@github-actions github-actions bot added C-Tests Issues and PRs related to the tests. C-Runtime Issues and PRs related to Boa's runtime features labels Mar 18, 2026
@jedel1043 jedel1043 enabled auto-merge March 18, 2026 18:15
@jedel1043 jedel1043 removed the Waiting On Author Waiting on PR changes from the author label Mar 18, 2026
@jedel1043 jedel1043 added this to the v1.0.0 milestone Mar 18, 2026
@jedel1043 jedel1043 added this pull request to the merge queue Mar 18, 2026
@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.42%. Comparing base (6ddc2b4) to head (096a0ca).
⚠️ Report is 886 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5046       +/-   ##
===========================================
+ Coverage   47.24%   59.42%   +12.17%     
===========================================
  Files         476      580      +104     
  Lines       46892    63170    +16278     
===========================================
+ Hits        22154    37538    +15384     
- Misses      24738    25632      +894     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into boa-dev:main with commit 50f0103 Mar 18, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Enhancement New feature or request C-Builtins PRs and Issues related to builtins/intrinsics C-Runtime Issues and PRs related to Boa's runtime features C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Response.redirect() and Response.json() static constructors to fetch runtime

2 participants